﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetDocumentInfo_V2]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetDocumentInfo_V2];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetDocumentInfo_V2]
    @DocID int
AS
BEGIN
SET NOCOUNT ON;

SELECT
        doc.Doc_Added_Date,
        doc.Doc_Status,
        doc.Flow_ID,
        doc.Step_ID,
        staff.Staff_ID,
        staff.Staff_Name,
        staff.Realname,
        flow.Flow_Name,
        step.Step_Name,
        data.*
    FROM 
        dbo.UDS_Flow_Document doc,
        dbo.UDS_Flow_Style_Data data,
        dbo.UDS_Staff staff,
        dbo.UDS_Flow flow,
        dbo.UDS_Flow_Step step        
    WHERE
        doc.Doc_ID = @DocID
        AND doc.Doc_ID = data.Doc_ID
        AND staff.Staff_ID = doc.Doc_Builder_ID
        AND doc.Flow_ID = flow.Flow_ID
        AND doc.Flow_ID = step.Flow_ID
        AND doc.Step_ID = step.Step_ID

END
GO
